/*
 * Created by JFormDesigner on Sun Nov 27 23:21:25 MSK 2011
 */

package view;

import calendar.Day;

import java.awt.*;
import java.awt.event.*;
import java.util.Calendar;
import javax.swing.*;

public class Organizer extends JFrame {

    private Day day;

    public Organizer() {
        initComponents();
        getContentPane().setBackground(new Color(255, 51, 0));

        day = new Day(Calendar.getInstance());
        //todo bad?
        AddNoteForm.getInstance().setModel(this, day);

    }

    private void TestButtonMouseClicked(MouseEvent e) {
        AddNoteForm.getInstance().setVisible(true);
    }

    public void updateNotes() {
        showNotesArea.setText(day.toString());
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        testButton = new JButton();
        showNotesScrollPanel = new JScrollPane();
        showNotesArea = new JTextArea();

        //======== this ========
        setTitle("Organizer");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container contentPane = getContentPane();
        contentPane.setLayout(null);

        //---- testButton ----
        testButton.setText("Add note");
        testButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                TestButtonMouseClicked(e);
            }
        });
        contentPane.add(testButton);
        testButton.setBounds(265, 270, 280, 90);

        //======== showNotesScrollPanel ========
        {

            //---- showNotesArea ----
            showNotesArea.setFont(new Font("Consolas", Font.ITALIC, 16));
            showNotesScrollPanel.setViewportView(showNotesArea);
        }
        contentPane.add(showNotesScrollPanel);
        showNotesScrollPanel.setBounds(180, 20, 440, 235);

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for(int i = 0; i < contentPane.getComponentCount(); i++) {
                Rectangle bounds = contentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = contentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            contentPane.setMinimumSize(preferredSize);
            contentPane.setPreferredSize(preferredSize);
        }
        setSize(800, 500);
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    private JButton testButton;
    private JScrollPane showNotesScrollPanel;
    private JTextArea showNotesArea;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
